package terra.network.packet.server.battle;

import org.jboss.netty.buffer.ChannelBuffer;

import terra.network.packet.Packet;

/**also used for block hit info. for it  - crit = 2 
 * targetOId = x;
 * damage = y;
 * */
public class HitInfo extends Packet {
	public final static byte BLOCK = 2;
	
	public int attackoId;
	public int targetOId;
	public int damage;
	public byte isCrit = 0;
	
	
	@Override
	public ChannelBuffer toBuffer() {
		ChannelBuffer buf = getNewBuffer();
		buf.writeByte(getId());
		buf.writeInt(attackoId);
		buf.writeInt(targetOId);
		buf.writeInt(damage);
		buf.writeByte(isCrit);
		return buf;
	}

	@Override
	public Packet fromBuffer(ChannelBuffer buf) {
		attackoId = buf.readInt();
		targetOId = buf.readInt();
		damage = buf.readInt();
		isCrit = buf.readByte();
		return this;
	}

	@Override
	public int getLength() {
		return 14;
	}

	@Override
	public boolean isDynamicLength() {
		return false;
	}

	@Override
	public byte getId() {
		return 28;
	}
	
	@Override
	public byte getPriority() {
		return PRIOR_HIGH;
	}

}
